package com.cheer.enums;

import cn.hutool.core.util.StrUtil;

/**
 * @author cheer
 */
public enum ReviewTypeEnum {

    COMMON(1, "普通审核"), // 行业审批
    INDEPENDENT(3, "团省委独立审批"),  // 团省委独立审批
    JOIN(2, "联合审核");

    private final Integer code;
    private final String message;

    ReviewTypeEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }


    /**
     * 判断是否是团省委独立审批
     * @return
     */
    public static boolean isIndependent(String path){

        if(StrUtil.isBlank(path)){
            return false;
        }
        // 团组织独立推荐 ID
        String independentFlage = "2";
        String[] split = path.split(",");
        for (int i = 0; i < split.length; i++) {
            String orgId = split[i];
            if(independentFlage.equals(orgId)){
                return true;
            }
        }
        return false;
    }


    public static ReviewTypeEnum getByCode(Integer code){

        ReviewTypeEnum[] values = ReviewTypeEnum.values();
        for (int i = 0; i < values.length; i++) {
            ReviewTypeEnum value = values[i];
            if(value.getCode().equals(code)){
                return value;
            }
        }
        return null;
    }


}
